package controller;


import entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import service.StudentService;

import java.util.ArrayList;
import java.util.List;

@RestController //@Controller+@ResponseBody
public class StudentController {
    @Autowired
    StudentService ss;

    @RequestMapping("/insert")
    public int insert(){
        Student student=new Student();
        student.setName("张三");
        student.setAge(20);
        student.setGender("男");
        return ss.insert(student);
    }


    @RequestMapping("/selectByPrimaryKey")
    public Student selectByPrimaryKey(){
        return ss.selectByPrimaryKey(10);
    }

@RequestMapping("/updateStudentByPrimaryKey")
    public int updateStudentByPrimaryKey(){
        Student student=new Student();
        student.setId(10);
        student.setName("tom");
        return ss.updateStudentByPrimaryKey(student);
}

    @RequestMapping("/selectByNameAndAge")
    public Student selectByNameAndAge(){
        return ss.selectByNameAndAge("tom",20);
    }

    @RequestMapping("/insertList")
    public int insertList(){
        Student student1=new Student("a1",20,"男");
        Student student2=new Student("a2",21,"男");
        Student student3=new Student("a3",22,"女");
        List<Student> list=new ArrayList<>();
                      list.add(student1);
                      list.add(student2);
                      list.add(student3);
        return ss.insertList(list);
    }





}




